package com.bite.ioc;

import com.bite.ioc.controller.HelloController;
import com.bite.ioc.controller.UserController;
import com.bite.ioc.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan(basePackages = "com.bite.ioc")
@SpringBootApplication//启动类
public class DemoApplication {

	public static void main(String[] args) {
		ApplicationContext context=SpringApplication.run(DemoApplication.class, args);
		HelloController bean = context.getBean(HelloController.class);
//		System.out.println(bean);
//		bean.sayHi();
		//通过Bean的名称获取
//		UserController usercon = (UserController) context.getBean("usercon");
//		usercon.sayHi();
//
//
//
//		UserController bean1 = context.getBean(UserController.class);
//		bean1.sayHi();


//		HelloController hellocontroller = (HelloController) context.getBean("helloController");
//		System.out.println(hellocontroller);
//		hellocontroller.sayHi();

//		HelloController helloController1 = context.getBean("helloController", HelloController.class);
//		System.out.println((helloController1));
//		helloController1.sayHi();

//		UserService bean2 = context.getBean(UserService.class);
//		bean2.doService();

//		UserComponent bean1 = context.getBean(UserComponent.class);
//		bean1.doComponent();

//		UserConfig bean2 = context.getBean(UserConfig.class);
//		bean2.doConfig();

//		UserRepo bean3 = context.getBean(UserRepo.class);
//		bean3.doRepo();

//		UserInfo bean4 = context.getBean(UserInfo.class);
//		System.out.println(bean4);

//		UserInfo bean4 = (UserInfo) context.getBean("userInfo1");
//		System.out.println(bean4);



	}

}
